<?php

class TController extends Controller {
    
    
    public function ossAction() {
        $table = Request::getParams('table');
        $filed = Request::getParams('filed', 'image');
        $pk = Request::getParams('pk', 'id');
        $defaultPk = 0;
        while(true) {
            $sql = "select * from {$table} where {$pk}>{$defaultPk} order by {$pk} asc limit 1000";
            $list = self::model('user')->query($sql)->fetchAll();
            if(!$list) {
                break;
            }
            $defaultPk = $list[count($list)-1][$pk];
            foreach ($list as $info) {
                $value = str_replace('app.chongshehui.com', 'app.majigo.net', strval($info[$filed]));
                $sql = "update {$table} set {$filed}='{$value}' where {$pk}={$info[$pk]}";
                echo $sql."\r\n";
                self::model('user')->execute($sql);
            } 
        }
    }
}
